package com.copa.gameStore.controller;

import com.copa.gameStore.application.GameNewsApplicationService;
import com.copa.gameStore.domain.GameNews;
import com.copa.gameStore.dto.GameNewsSearchDto;
import com.copa.gameStore.vo.GameNewsDetailVo;
import com.copa.gameStore.vo.ResponseVo;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.time.LocalDate;
import java.util.List;
import java.util.TreeMap;

/**
 * @author copa
 * @createDate 2022-09-26 14:24
 * @function
 */
@RestController
@Api(tags = "游戏资讯服务")
public class GameNewsController {

    @Resource
    private GameNewsApplicationService gameNewsApplicationService;

    @ApiOperation("查询游戏资讯详情")
    @GetMapping("{id}")
    public ResponseVo<GameNewsDetailVo> get(@PathVariable("id") Long id) {
        return gameNewsApplicationService.get(id);
    }

    @ApiOperation("查询游戏资讯概要")
    @GetMapping("list")
    public ResponseVo<TreeMap<LocalDate,List<GameNews>>> getByYearMonth(GameNewsSearchDto gameNewsSearchDto) {
        return gameNewsApplicationService.getByYearMonth(gameNewsSearchDto);
    }
}
